package network.tcp;

import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * @author mubei
 * @date 2021/12/4
 * @description  客户端
 */
public class Client {

    public static void main(String[] args) throws Exception {
        // 地址和端口
        InetAddress inetAddress = InetAddress.getByName("127.0.0.1");
        int port = 9999;

        // 创建socket连接
        Socket socket = new Socket(inetAddress, port);

        // 输出
        OutputStream os = socket.getOutputStream();
        os.write("hello,world".getBytes());

        socket.close();
        os.close();

    }
}
